<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
	<HEAD>
		<META CONTENT="text/html; charset=iso-8859-1" HTTP-EQUIV="Content-Type">
		<TITLE>PI.JS > pi.cache</TITLE>
		<LINK HREF="../../../inc/template.css" REL="stylesheet">
		<LINK HREF="../../../inc/template.css" REL="stylesheet">
		<SCRIPT SRC="../../../source/pi.1.1.min.js" TYPE="text/javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/template.js" TYPE="text/javascript"></SCRIPT>
		<SCRIPT SRC="../../../plugin/pi.cache/pi.cache.js" TYPE="text/javascript"></SCRIPT>
		<LINK HREF="../../../inc/sh/SyntaxHighlighter.css" TYPE="text/css" REL="stylesheet">
		<SCRIPT SRC="../../../inc/sh/shCore.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushJScript.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushCss.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushXml.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushPhp.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushPython.js" LANGUAGE="javascript"></SCRIPT>
	</HEAD>
	<BODY>
		<A HREF="/" ID="header" CLASS="Header">
			<EM></EM>
		</A>
		<DIV CLASS="Index">
			<DIV ID="indexContainer" CLASS="ListContainer">
				<A HREF="../../../index.html" CLASS="Button "><EM>About Pi</EM></A>
				<A HREF="../../../pages/Downloads" CLASS="Button "><EM>Downloads</EM></A>
				<A HREF="../../../documentation/index.html" CLASS="Button SelectedButton"><EM>Documentation</EM></A>
				<DIV CLASS="SubNavigation">
					<DIV>
						<H2 CLASS="Title">Essential Documents</H2>
						<UL>
							<LI>
								<A STYLE="" HREF="../../../documentation/essential/Getting Started to pi.js/">Getting Started to pi.js</A>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/essential/Object Oriented Programming with pi.js/">Object Oriented Programming with pi.js</A>
							</LI>
						</UL>
					</DIV><DIV>
						<H2 CLASS="Title">Reference</H2>
						<UL>
							<LI>
								<A STYLE="" HREF="../../../documentation/env/pi.env/">pi.env</A>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/get/pi.get/">pi.get</A>
							</LI><LI>
								<A STYLE="font-weight:bold" HREF="../../../documentation/util/pi.util/">pi.util</A>
								<UL>
									<LI>
										<A HREF="../../../documentation/util/pi.util.Array/">pi.util.Array</A>
									</LI><LI>
										<A HREF="../../../documentation/util/pi.util.Element/">pi.util.Element</A>
									</LI><LI>
										<A HREF="../../../documentation/util/pi.util.Hash/">pi.util.Hash</A>
									</LI><LI>
										<A HREF="../../../documentation/util/pi.util.Number/">pi.util.Number</A>
									</LI><LI>
										<A HREF="../../../documentation/util/pi.util.String/">pi.util.String</A>
									</LI>
								</UL>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/base/pi.base/">pi.base</A>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/element/pi.element/">pi.element</A>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/xhr/pi.xhr/">pi.xhr</A>
							</LI><LI>
								<SPAN STYLE="font-weight:bold">Native Objects</SPAN>
								<UL>
									<LI>
										<A HREF="../../../documentation/Native Objects/Array/">Array</A>
									</LI><LI>
										<A HREF="../../../documentation/Native Objects/Function/">Function</A>
									</LI><LI>
										<A HREF="../../../documentation/Native Objects/Number/">Number</A>
									</LI><LI>
										<A HREF="../../../documentation/Native Objects/String/">String</A>
									</LI>
								</UL>
							</LI><LI>
								<SPAN STYLE="font-weight:bold">Plugins</SPAN>
								<UL>
									<LI>
										<A HREF="../../../documentation/plugin/pi.comet/">pi.comet</A>
									</LI><LI>
										<SPAN>pi.cache</SPAN>
									</LI><LI>
										<SPAN>pi.layer</SPAN>
									</LI><LI>
										<A HREF="../../../documentation/plugin/pi.storage/">pi.storage</A>
									</LI><LI>
										<SPAN>pi.window</SPAN>
									</LI>
								</UL>
							</LI>
						</UL>
					</DIV>
				</DIV>
				<A HREF="http://groups.google.com/group/pi-js" CLASS="Button"><EM>Developer Forum</EM></A>
				<A HREF="http://code.google.com/p/pi-js/issues/list" CLASS="Button"><EM>Issues</EM></A>
			</DIV>
		</DIV>
		<!-- <h3 class="ContentNav" id="contentTitle">
			<div>
				<a class="Sel">index.html</a>
			</div>
		</h3>-->
		<DIV ID="documentationContent" CLASS="Content">
			<DIV CLASS="Pad">
				<H1 CLASS="Name">pi.cache<EM CLASS="DocumentationTitleVersion">2008-09-10 12:01:37</EM></H1>
				<DIV>
				<H2 CLASS="Title">Summary</H2>
				Client-side cache collector.pi.storage ile birlestirilebilmesi sayesinde kalici cache koleksiyonlari yapilabilir.
				</DIV>
				<DIV CLASS="Text">
					<H2 CLASS="Title">Syntax</H2>
<CODE>var data  = new pi.cache(<EM>collection name</EM>)
if( data.has(<EM>item name</EM>) )
	alert( cache.get(<EM>item name</EM>) );
else {
	cache.append(
		new pi.cache.item(<EM>item name</EM>).environment.setData(<EM>data</EM>);
	);
}
</CODE>
				</DIV>
				<DIV CLASS="PageListContainer">
					<DIV CLASS="Page">
						<H2 CLASS="Title">Methods</H2>
						<DIV CLASS="PageItem">
							<A HREF="Methods/append/" CLASS="PageItemTitle">append</A>
							<DIV CLASS="PageItemSummary">Adds new item to the collection.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/clear/" CLASS="PageItemTitle">clear</A>
							<DIV CLASS="PageItemSummary">Removes all items of the specified collection.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/get/" CLASS="PageItemTitle">get</A>
							<DIV CLASS="PageItemSummary">Returns value of the specified cache item.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/has/" CLASS="PageItemTitle">has</A>
							<DIV CLASS="PageItemSummary">Returns a boolean value indicating whether the specified collection has the specified item or not.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/remove/" CLASS="PageItemTitle">remove</A>
							<DIV CLASS="PageItemSummary">Removes given item from the collection.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/environment.getIsPermanent/" CLASS="PageItemTitle">environment.getIsPermanent</A>
							<DIV CLASS="PageItemSummary">Returns whether the collection is permanent.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/environment.setIsPermanent/" CLASS="PageItemTitle">environment.setIsPermanent</A>
							<DIV CLASS="PageItemSummary">Koleksiyonun kalici olup olmayacagini belirlememizi saglar.Eger</DIV>
						</DIV>
					</DIV>
				</DIV>
				<DIV CLASS="Block">
					<H1>Examples</H1>
					<DIV CLASS="Example">
						<H1>Example #1: 1 saniye aralikla server'dan unixtime'i al, cache'te tut.Ve cache'i 10 saniyede bir tazele.</H1>
							<DIV CLASS="View">
								<DIV ID="content"></DIV><SCRIPT SRC="examples/unixtime.js" TYPE="text/javascript"></SCRIPT>
							</DIV>
							<H2>Source files of the above example:</H2>
							<DIV>
								<H3>examples/unixtime.html</H3>
								<PRE NAME="code" CLASS="html">&lt;div id="content">&lt;/div></PRE>
							</DIV><DIV>
								<H3>examples/unixtime.js</H3>
								<PRE NAME="code" CLASS="js">var cache = new pi.cache("NewCollection");
var get = function(){
	var value,source;
	
	if(cache.has("unixtime")){
		source = "cache";
		value = cache.get("unixtime");
	} else {
		source = "server";
		value = pi.xhr.get("examples/unixtime.php").responseText;
		
		cache.append(
			new pi.cache.item("unixtime").environment.setData(value).environment.setExpirationSliding(10000)
		);
	};
	pi.get("content").innerHTML="&lt;b>Browser time:&lt;/b>"+String(Number(new Date)).substring(0,10)
	pi.get("content").innerHTML+="&lt;br />&lt;b>Source:&lt;/b> "+source;
	pi.get("content").innerHTML+="&lt;br />&lt;b>Data was got from server:&lt;/b>"+value;
	setTimeout(get,1000);
};

get();</PRE>
							</DIV>
							<DIV>
								<DIV>
									<H3>examples/unixtime.php</H3>
									<PRE NAME="code" CLASS="php">&lt;? print time(); ?></PRE>
								</DIV>
							</DIV>
					</DIV>
				</DIV>
			</DIV>
		</DIV>
		<DIV CLASS="Clean"></DIV>
	</BODY> 
</HTML>